package com.open.source.component.redis;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ZonLen since on 2022/7/14 下午8:09
 */
@RestController
public class RedisController {

  @Autowired
  private StringRedisTemplate stringRedisTemplate;

  @GetMapping("/get")
  public Object get(@RequestParam String key) {
    return stringRedisTemplate.opsForValue().get(key);
  }

  @PostMapping("/delete")
  public String delete(@RequestBody List<String> keys) {
    stringRedisTemplate.delete(keys);
    return "success";
  }
}
